package router

import (
	pingController "gitee.com/krio/grpc-gin-client/app/controller/ping"
	"gitee.com/krio/grpc-gin-client/dto/route"
	"gitee.com/krio/grpc-gin-client/middleware/api"
	"github.com/gin-gonic/gin"
)

// InitRouter 路由器
func InitRouter(g *gin.Engine) *gin.Engine {
	// swagger API文档
	g = initSwagger(g)

	// 全局中间件
	g.Use(
		api.Recover, // 全局异常处理
		api.Cors,    // 跨域
		api.Tracer,  // 链路追踪
	)
	// ping
	g.GET(route.ApiPingGET, apiWrapper(pingController.Ping))

	return g
}
